package com.lhh.mapper;


import com.lhh.entity.User;
import com.lhh.entity.Validate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    //根据用户名查询用户
    @Select("select * from user where userName = #{userName}")
    public User getUserByName(String userName);

    //根据邮箱地址查询用户
    @Select("select * from user where email = #{email}")
    public User getUserByEmail(String email);

    //根据id查询用户
    @Select("select * from user where user_id = #{user_id}")
    public User getInfo(Integer id);

    //添加用户账号、密码(注册)
    @Insert("insert into user (userName,passwd,status,registTime,telphone,email)  values (#{userName}, #{passwd}, #{status}, #{registTime},#{telphone}, #{email})")
    public int addUser(User user);


    //修改用户信息
    @Update("update user set userName=#{userName},email=#{email},telphone=#{telphone} where id =#{id}")
    public int updateUser(User user);

    //修改用户密码,token,更新时间
    @Update("update user set passwd=#{passwd},token=#{token},updateTime=#{updateTime} where email = #{email}")
    public int modifypassword(User user);

}
